// NTWindow.h
#pragma once
#include <windows.h>
#include <stdio.h>

namespace ANvDbg
{
    class NTWindow
    {
    public:
        NTWindow();

    public:
        static LRESULT CALLBACK OpenGLNTWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
        static ATOM RegisterNTWindow(LPCTSTR class_name, DWORD style);

        template<class T>
        static T* CreateNTWindow(LPCTSTR class_name, LPCTSTR window_name, DWORD style)
        {
            HWND hwnd = CreateWindowEx(NULL, class_name, window_name, style,
                200, 200, 800, 600, NULL, NULL, g_app_instance, NULL);

            T* window = new T;
            window->m_hwnd = hwnd;

            SetWindowLongPtr(window->m_hwnd, GWL_USERDATA, (LONG_PTR)window);

            return window;
        }

    public:
        virtual void Init();
        HDC GetWindowDC() { return m_dc; }
        void ShowNTWindow(bool is_show);

    public:
        static HINSTANCE g_app_instance;

    protected:
        virtual void OnClose(WPARAM wParam, LPARAM lParam);
        virtual void OnLButtonDown(WPARAM wParam, LPARAM lParam);
        virtual void OnLButtonUp(WPARAM wParam, LPARAM lParam);
        virtual void OnRButtonDown(WPARAM wParam, LPARAM lParam);
        virtual void OnRButtonUp(WPARAM wParam, LPARAM lParam);
        virtual void OnKeyDown(WPARAM wParam, LPARAM lParam);
        virtual void OnKeyUp(WPARAM wParam, LPARAM lParam);

    protected:
        HWND m_hwnd;
        HDC m_dc;
        bool m_is_show;
        int m_window_width;
        int m_window_height;
    };
}